package org.hzero.order.app.service.impl;


import java.util.List;

import org.hzero.order.app.service.OrderService;
import org.hzero.order.domain.entity.dto.OrderDTO;
import org.hzero.order.infra.constant.OrderStatus;
import org.hzero.order.infra.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author xiuiqng.Yang-Estelle-양수청
 * @date 2019/8/5 16:19
 */
/**
 * ExampleServiceImpl
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<OrderDTO> select(OrderDTO attr) {
        return orderMapper.select(attr);
    }

    @Override
    public List<OrderDTO> select(String orderNumber) {
        return orderMapper.selectByOrderNumber(orderNumber);
    }

    @Override
    public String selectOrderDesc(String orderNumber, String orderStatus) {
        return orderMapper.selectDescByStatus(orderNumber, orderStatus);
    }

    @Override
    public String chooseStatus(String orderStatus) {
        switch (orderStatus){
            case "NEW": return OrderStatus.NEW.getDesc();
            case "SUBMITED": return OrderStatus.SUBMITED.getDesc();
            case "APPROVED": return OrderStatus.APPROVED.getDesc();
            case "REJECTED": return OrderStatus.REJECTED.getDesc();
            case "CLOSED": return OrderStatus.CLOSED.getDesc();
            default: return OrderStatus.NOT_EXIST.getDesc();
        }
    }

}
